package com.tencreat.common.core.domain.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.tencreat.common.annotation.Excel;
import com.tencreat.common.annotation.Excel.ColumnType;
import com.tencreat.common.annotation.Excel.Type;
import com.tencreat.common.annotation.Excels;
import com.tencreat.common.core.domain.BaseEntity;
import com.tencreat.common.enums.Sex;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.Getter;
import lombok.ToString;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

/**
 * 用户对象 sys_user
 *
 * @Company: 深圳腾创互联科技有限公司
 * @link: https://tencreat.com/#/
 * @author tencreat
 */
@Data
@ToString
public class SysUser extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** 用户ID */
    private Long userId;

    /** 部门ID */
    private Long deptId;

    /** 用户账号 */
    @Excel(name = "用户账号",sort = 2)
    private String userName;

    /** 用户昵称 */
    @Excel(name = "用户名称",sort = 4)
    private String nickName;

    /** 用户邮箱 */
//    @Excel(name = "用户邮箱")
    private String email;

    /** 手机号码 */
    @Excel(name = "手机号码",sort = 3)
    private String phonenumber;

    /** 用户性别 */

    @Getter
    private Sex sex;


    @Getter
    @Excel(name = "备注",sort = 5)
    @TableField(exist = false)
    private String remark2;


    @Getter
    @Excel(name = "创建时间",sort = 7,dateFormat = "yyyy-MM-dd HH:mm:ss")
    @TableField(exist = false)
    private LocalDateTime createTime2;

    /** 用户头像 */
    private String avatar;

    /** 密码 */
    private String password;

    /** 盐加密 */
    private String salt;

    /** 帐号状态（0正常 1停用） */
    @Excel(name = "状态", readConverterExp = "0=正常,1=停用",sort = 6)
    private String status;

    /** 删除标志（0代表存在 2代表删除） */
    private String delFlag;

    /** 最后登录IP */
    private String loginIp;

    /** 最后登录时间 */
    private Date loginDate;

    /***
     * 分页
     */
    private Integer num;

    /***
     * 分页
     */
    private Integer size;



    /** 部门对象 */
    private SysDept dept;

    /** 供应商订单收益 */
    private BigDecimal supplierEarnings;
    /** 供应商订单待结算 */
    private BigDecimal supplierSettlement;
    /** 供应商订单退款 */
    private BigDecimal supplierRefund;

    /** 店铺订单收益 */

    @Getter
    private BigDecimal storeEarnings;
    /** 店铺订单待结算 */

    @Getter
    private BigDecimal storeSettlement;
    /** 店铺订单退款 */

    @Getter
    private BigDecimal storeRefund;

    /** 角色对象 */

    @Getter
    @Excels({
      @Excel(sort = 1, name = "角色",targetAttr = "roleName",type = Type.EXPORT)
    })
    private SysRole role;

    private List<SysRole> roles;

    /** 角色组 */
    private Long[] roleIds;

    /** 岗位组 */
    private Long[] postIds;

    private Long tenantId;

    @Getter

    private Long roleId;


    /**
     * 描述信息  当日销量
     * @Author yaoruiqi
     * @Date: 2023/10/16 09:05
     */

    @Getter
    private BigDecimal  todaySales;


    /**
     * 描述信息  本月销量
     * @Author yaoruiqi
     * @Date: 2023/10/16 09:06
*/
    @Getter
    private BigDecimal monthSales;

    /**
     * 描述信息  累计销量
     * @Author yaoruiqi
     * @Date: 2023/10/16 09:07
     */

    @Getter
    private BigDecimal sumSales;




    @Getter
    @Excel(name = "审核状态",sort = 8,readConverterExp = "0=待审核,1=审核成功,2=审核驳回")
    @ApiModelProperty(value = "审核状态：0 待审核, 1 审核成功, 2 审核驳回")
    private Integer approvalStatus;


    @Getter
    @ApiModelProperty(value = "0 管理员 1店铺 2 供应商")
    private Integer store;



    public void setApprovalStatus(Integer approvalStatus) {
        this.approvalStatus = approvalStatus;
    }

    public SysUser()
    {

    }

    public void setStore(Integer store) {
        this.store = store;
    }

    public Integer getNum() {
        return num;
    }

    public void setNum(Integer num) {
        this.num = num;
    }

    public Integer getSize() {
        return size;
    }

    public void setSize(Integer size) {
        this.size = size;
    }

    public Long getTenantId() {
        return tenantId;
    }

    public void setTenantId(Long tenantId) {
        this.tenantId = tenantId;
    }

    public SysUser(Long userId)
    {
        this.userId = userId;
    }

    public Long getUserId()
    {
        return userId;
    }

    public void setUserId(Long userId)
    {
        this.userId = userId;
    }

    public boolean isAdmin()
    {
        return isAdmin(this.userId);
    }

    public static boolean isAdmin(Long userId)
    {
        return userId != null && 1L == userId;
    }

    public Long getDeptId()
    {
        return deptId;
    }

    public void setDeptId(Long deptId)
    {
        this.deptId = deptId;
    }

    public BigDecimal getSupplierEarnings() {
        return supplierEarnings;
    }

    public void setSupplierEarnings(BigDecimal supplierEarnings) {
        this.supplierEarnings = supplierEarnings;
    }

    public BigDecimal getSupplierSettlement() {
        return supplierSettlement;
    }

    public void setSupplierSettlement(BigDecimal supplierSettlement) {
        this.supplierSettlement = supplierSettlement;
    }

    public BigDecimal getSupplierRefund() {
        return supplierRefund;
    }

    public void setSupplierRefund(BigDecimal supplierRefund) {
        this.supplierRefund = supplierRefund;
    }

    @Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符")
    public String getNickName()
    {
        return nickName;
    }

    public void setNickName(String nickName)
    {
        this.nickName = nickName;
    }

    @NotBlank(message = "用户账号不能为空")
    @Size(min = 0, max = 30, message = "用户账号长度不能超过30个字符")
    public String getUserName()
    {
        return userName;
    }

    public void setUserName(String userName)
    {
        this.userName = userName;
    }

    @Email(message = "邮箱格式不正确")
    @Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
    public String getEmail()
    {
        return email;
    }

    public void setEmail(String email)
    {
        this.email = email;
    }

    @Size(min = 0, max = 11, message = "手机号码长度不能超过11个字符")
    public String getPhonenumber()
    {
        return phonenumber;
    }

    public void setPhonenumber(String phonenumber)
    {
        this.phonenumber = phonenumber;
    }

    public String getAvatar()
    {
        return avatar;
    }

    public void setAvatar(String avatar)
    {
        this.avatar = avatar;
    }

	@JsonIgnore
    @JsonProperty
    public String getPassword()
    {
        return password;
    }

    public void setPassword(String password)
    {
        this.password = password;
    }

    public String getSalt()
    {
        return salt;
    }

    public void setSalt(String salt)
    {
        this.salt = salt;
    }

    public String getStatus()
    {
        return status;
    }

    public void setStatus(String status)
    {
        this.status = status;
    }

    public String getDelFlag()
    {
        return delFlag;
    }

    public void setDelFlag(String delFlag)
    {
        this.delFlag = delFlag;
    }

    public String getLoginIp()
    {
        return loginIp;
    }

    public void setLoginIp(String loginIp)
    {
        this.loginIp = loginIp;
    }

    public Date getLoginDate()
    {
        return loginDate;
    }

    public void setLoginDate(Date loginDate)
    {
        this.loginDate = loginDate;
    }

    public SysDept getDept()
    {
        return dept;
    }

    public void setDept(SysDept dept)
    {
        this.dept = dept;
    }

    public List<SysRole> getRoles()
    {
        return roles;
    }

    public void setRoles(List<SysRole> roles)
    {
        this.roles = roles;
    }

    public Long[] getRoleIds()
    {
        return roleIds;
    }

    public void setRoleIds(Long[] roleIds)
    {
        this.roleIds = roleIds;
    }

    public Long[] getPostIds()
    {
        return postIds;
    }

    public void setPostIds(Long[] postIds)
    {
        this.postIds = postIds;
    }

    public void setSex(Sex sex) {
        this.sex = sex;
    }

    public void setRemark2(String remark2) {
        this.remark2 = remark2;
    }

    public void setCreateTime2(LocalDateTime createTime2) {
        this.createTime2 = createTime2;
    }

    public void setStoreEarnings(BigDecimal storeEarnings) {
        this.storeEarnings = storeEarnings;
    }

    public void setStoreSettlement(BigDecimal storeSettlement) {
        this.storeSettlement = storeSettlement;
    }

    public void setStoreRefund(BigDecimal storeRefund) {
        this.storeRefund = storeRefund;
    }

    public void setRole(SysRole role) {
        this.role = role;
    }

    public void setRoleId(Long roleId) {
        this.roleId = roleId;
    }

    public void setTodaySales(BigDecimal todaySales) {
        this.todaySales = todaySales;
    }

    public void setMonthSales(BigDecimal monthSales) {
        this.monthSales = monthSales;
    }

    public void setSumSales(BigDecimal sumSales) {
        this.sumSales = sumSales;
    }

}
